package com.speily.example.common.utils.bean;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * 继承Spring bean工具类<br>
 * {@link net.sf.cglib.beans.BeanMap}
 */
public final class BeanUtil extends org.springframework.beans.BeanUtils {

    private BeanUtil() {
    }

    /**
     * springbeanutill 未处理 null
     *
     * @param bean
     * @param <T>
     * @return
     */
    public static <T> Map<String, Object> beanToMap(T bean) {
        Map<String, Object> map = new HashMap();
        if (bean != null) {
            net.sf.cglib.beans.BeanMap beanMap = net.sf.cglib.beans.BeanMap.create(bean);
            Iterator var3 = beanMap.keySet().iterator();

            while (var3.hasNext()) {
                Object key = var3.next();
                if (beanMap.get(key) != null && !beanMap.get(key).equals("null")) {
                    map.put(key + "", beanMap.get(key));
                }
            }
        }

        return map;
    }
}
